package com.apes.hr.transfer.service;

import com.apes.framework.api.DomainService;
import com.apes.hr.transfer.model.TransferApplicationExecution;
import com.apes.hr.transfer.model.TransferApplicationItem;
import com.apes.hr.transfer.repository.TransferApplicationItemRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能：调动项目
 *
 * @author Fengjiajing
 * @create 2018-09-03 10:07
 */
@Service("hrTransferApplicationItemService")
public class TransferApplicationItemService  extends DomainService {

    @Autowired
    public TransferApplicationItemRepository itemnRepository;

    /**
     * 功能：保存 更新执行标识 为真
     * @param
     */
    public void updateItemIconExecute(TransferApplicationItem item){
        Integer id = item.getId();
        itemnRepository.updateItemIconExecute(id,true);
    }


    /**
     * 功能：更新 角色
     * @param
     */
    public void updateItem(TransferApplicationExecution itemExec,String yRoleList){
        Integer itemId  = itemExec.getTransferApplicationItems().getId();
//      TransferApplicationItem item= itemnRepository.findOne(itemId);
      //  item.setRoleList(yRoleList);
        // itemnRepository.saveAndFlush(item);
        itemnRepository.updateItemRoles(yRoleList, itemId+"");

    }
    /**
     * 功能：查找
     * @param
     */
    public List<TransferApplicationItem> findById(Integer id){
       return itemnRepository.findAllById(id);
    }

    /**
     * 功能：删除
     * @param
     */
    public void delete(List<TransferApplicationItem> listItems){
        itemnRepository.deleteAll(listItems);
    }
}
